package cc.admin.modules.graduate.config;

import com.itextpdf.text.log.Logger;
import com.itextpdf.text.log.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;

//继承WebSocketClient，重写监听方法和构造方法
@Slf4j
public class MyWebSocketClient extends WebSocketClient {
    private static final Logger logger = LoggerFactory.getLogger(MyWebSocketClient.class);
    public MyWebSocketClient(URI serverUri){
        super(serverUri);
    }
    @Override
    public void onOpen(ServerHandshake serverHandshake) {
        logger.info("客户端和ws服务已经连接上了");
    }
    @Override
    public void onMessage(String s) {
        logger.info("收到服务器消息："+ s);
    }
    @Override
    public void onClose(int i, String s, boolean b) {
        logger.info("客户端和服务端连接关闭");
        logger.info(String.valueOf(i));
        logger.info(s);
        logger.info(String.valueOf(b));
    }
    @Override
    public void onError(Exception e) {
        logger.info("通信发生错误");
    }
}
